mod imp;
mod note_window;

use glib::{clone, Object};
use gio::SimpleAction;
use gtk::{gio, glib, Application};
use adw::ApplicationWindow;
use adw::prelude::{ActionMapExt, GtkWindowExt};

glib::wrapper!{
    pub struct MainWindow(ObjectSubclass<imp::MainWindow>)
	@extends adw::ApplicationWindow, gtk::ApplicationWindow, gtk::Window, gtk::Widget,
    @implements gio::ActionGroup, gio::ActionMap, gtk::Accessible, gtk::Buildable,
    gtk::ConstraintTarget, gtk::Native, gtk::Root, gtk::ShortcutManager;
}

impl MainWindow {
    pub fn new(app: &adw::Application) -> Self {
	Object::builder().property("application", app).build()
    }

    fn setup_actions(&self) {
	let menu_preferences = SimpleAction::new("menu_preferences", None);
	menu_preferences.connect_activate(clone!( @weak self as win => move |_,_| { 
	    println!("clicked menu preferences");
	}));

	self.add_action(&menu_preferences);

	let menu_about = SimpleAction::new("menu_about", None);
	menu_about.connect_activate(clone!( @weak self as win => move |_,_| { 
	    println!("clicked menu about");
	}));

	self.add_action(&menu_about);

	let note_menu_edit = SimpleAction::new("note_menu_edit", None);
	note_menu_edit.connect_activate(clone!( @weak self as win => move |_,_| { 
	    println!("clicked note menu edit");
	}));

	self.add_action(&note_menu_edit);

	let note_menu_delete = SimpleAction::new("note_menu_delete", None);
	note_menu_delete.connect_activate(clone!( @weak self as win => move |_,_| { 
	    println!("clicked note menu delete");
	}));

	self.add_action(&note_menu_delete);
	
	let new_note = SimpleAction::new("new_note", None);
	new_note.connect_activate(clone!( @weak self as win => move |_,_| { 
	    println!("clicked new note");
	    let nw = note_window::NoteWindow::new();
	    nw.present();
	}));

	self.add_action(&new_note);
    }


}
